<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增采购清单')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-purchaseList-add">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">合同编号：</label>
                <div class="col-sm-8">
                    <input name="contractCode" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">供应商名称：</label>
                <div class="col-sm-8">
                    <input name="supplierName" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">产品名称：</label>
                <div class="col-sm-8">
                    <input name="productName" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">金额：</label>
                <div class="col-sm-8">
                    <input name="totalAmount" class="form-control" type="number" step="0.01" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">定货数量：</label>
                <div class="col-sm-8">
                    <input name="orderQuantity" class="form-control" type="number" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">订货人：</label>
                <div class="col-sm-8">
                    <input name="purchaser" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">合同日期：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="contractDate" class="form-control" placeholder="yyyy-mm-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">付款日期：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="paymentDate" class="form-control" placeholder="yyyy-mm-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">到货日期：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="arrivalDate" class="form-control" placeholder="yyyy-mm-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">是否含税：</label>
                <div class="col-sm-8">
                    <div class="radio-box">
                        <input type="radio" id="isTaxIncluded1" name="isTaxIncluded" value="1" checked>
                        <label for="isTaxIncluded1">是</label>
                    </div>
                    <div class="radio-box">
                        <input type="radio" id="isTaxIncluded2" name="isTaxIncluded" value="0">
                        <label for="isTaxIncluded2">否</label>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">是否到货：</label>
                <div class="col-sm-8">
                    <div class="radio-box">
                        <input type="radio" id="isDelivered1" name="isDelivered" value="1">
                        <label for="isDelivered1">是</label>
                    </div>
                    <div class="radio-box">
                        <input type="radio" id="isDelivered2" name="isDelivered" value="0" checked>
                        <label for="isDelivered2">否</label>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">发票情况：</label>
                <div class="col-sm-8">
                    <select name="invoiceStatus" class="form-control">
                        <option value="0" selected>未开票</option>
                        <option value="1">已开票</option>
                        <option value="2">部分开票</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">用途：</label>
                <div class="col-sm-8">
                    <input name="usagePurpose" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">货期：</label>
                <div class="col-sm-8">
                    <input name="deliveryPeriod" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <textarea name="remark" class="form-control" rows="3"></textarea>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var prefix = ctx + "purchase/purchaseList";
        
        $("input[name='contractDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            language: 'zh-CN',
            autoclose: true
        });
        
        $("input[name='paymentDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            language: 'zh-CN',
            autoclose: true
        });
        
        $("input[name='arrivalDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            language: 'zh-CN',
            autoclose: true
        });
        
        $("#form-purchaseList-add").validate({
            onkeyup: false,
            rules: {
                contractCode: {
                    required: true
                },
                supplierName: {
                    required: true
                },
                productName: {
                    required: true
                },
                totalAmount: {
                    required: true,
                    number: true,
                    min: 0
                },
                orderQuantity: {
                    required: true,
                    digits: true,
                    min: 1
                },
                purchaser: {
                    required: true
                }
            },
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-purchaseList-add').serialize());
            }
        }
    </script>
</body>
</html>